<template>
  <div>

    <el-menu
      :default-active="defaultActiveIndex"
      @select="handleSelect"
      :router="true"
      :default-openeds="openeds"
      :collapse="isCollapse"
    >
      <el-menu-item index="/manager/basedata/user">
        <i class="el-icon-setting"></i>
        <span slot="title">基础数据</span>
      </el-menu-item>
      <el-submenu index="2" :unique-opened="true">
        <template slot="title">
          <i class="el-icon-menu"></i>资产管理
        </template>
        <el-menu-item index="/manager/asset">&emsp;&ensp;现有资产</el-menu-item>
        <el-menu-item index="/manager/prepaid_asset">&emsp;&ensp;报废资产</el-menu-item>
      </el-submenu>
      <el-submenu index="6" :unique-opened="true">
        <template slot="title">
          <i class="el-icon-s-claim"></i>订购管理
        </template>
        <el-menu-item index="/manager/order_application">&emsp;&ensp;订购申请</el-menu-item>
        <el-menu-item index="/manager/unfinish_orderlist">&emsp;&ensp;未完成订单</el-menu-item>
        <el-menu-item index="/manager/unread_orderlist">&emsp;&ensp;待审批订单</el-menu-item>
      </el-submenu>
      <el-submenu index="7" :unique-opened="true">
        <template slot="title">
          <i class="el-icon-s-claim"></i>调拨管理
        </template>
        <el-menu-item index="/manager/trans_application">&emsp;&ensp;调拨申请</el-menu-item>
        <el-menu-item index="/manager/trans_list">&emsp;&ensp;调拨申请单</el-menu-item>
        <el-menu-item index="/manager/unread_translist">&emsp;&ensp;待审批调拨单</el-menu-item>
      </el-submenu>
      <el-menu-item index="/manager/borrow/borrow_application">
        <i class="el-icon-setting"></i>
        <span slot="title">借用管理</span>
      </el-menu-item>
      <el-submenu index="9" :unique-opened="true">
        <template slot="title">
          <i class="el-icon-s-claim"></i>库存管理
        </template>
        <el-menu-item index="/manager/stock_input_check">&emsp;&ensp;验收资产</el-menu-item>
        <el-menu-item index="/manager/stock_address">&emsp;&ensp;资产地点</el-menu-item>
        <el-menu-item index="/manager/stock_io_record">&emsp;&ensp;资产出入记录</el-menu-item>
        <el-menu-item index="/manager/stock_maintain">&emsp;&ensp;故障/维护申请</el-menu-item>
        <el-menu-item index="/manager/worthless_handle">&emsp;&ensp;报废处理</el-menu-item>
      </el-submenu>
      <el-submenu index="10" :unique-opened="true">
        <template slot="title">
          <i class="el-icon-s-claim"></i>维修管理
        </template>
        <el-menu-item index="/manager/maintain_work">&emsp;&ensp;待维修/维护</el-menu-item>
        <el-menu-item index="/manager/regular_check">&emsp;&ensp;定期检测</el-menu-item>
        <el-menu-item index="/manager/check_record">&emsp;&ensp;检测记录</el-menu-item>
        <el-menu-item index="/manager/repair_record">&emsp;&ensp;维修记录</el-menu-item>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
export default {
  name: "sysAsider",
  data() {
    return {
      isCollapse: false,
      defaultActiveIndex: "",
      openeds: ["8", "6", "7", "9"]
    };
  },
  created() {
    this.RefreshActiveIndex();
  },
  methods: {
    handleSelect(index) {
      this.defaultActiveIndex = index;
    },
    //更新激活状态
    RefreshActiveIndex() {
      let cur_path = this.$route.path;
      this.defaultActiveIndex = cur_path;
    }
  },
  watch: {
    $route: function() {
      // 路由改变时执行
      //console.info("to.path:" + to.path);
      this.RefreshActiveIndex();
    }
  }
};
</script>
<style>
 .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
  }
</style>